<template>
    <div class="box">
        <!-- 盒子 -->
      <div class="box-item" :class="{ active: isToggle }">
        <!-- 登录表单 -->
        <div class="form-box ">
        </div>
  
        <!-- 注册表单 -->
        <div class="form-box register">
        </div>
  <!-- 遮罩层 -->
        <div class="toggle-box">
          <div class="one toggle-left">
            <button class="btn " @click="toggleForm">注册</button>
          </div>
  
          <div class="one toggle-right">
            <button class="btn" @click="toggleForm">登录</button>
          </div>
        </div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from "vue";
  const isToggle = ref(false);
  const toggleForm = () => {
    isToggle.value = !isToggle.value;
  };
  
  </script>
  
  <style scoped>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  .box {
    display: flex;
    justify-content: center; 
    align-items: center; 
    height: 100vh;
  }
  .box-item {
    position: relative;
    width: 850px;
    height: 550px;
    background-color: #fff;
    border-radius: 30px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
  }
  
  .box-item.active .toggle-box::before {
    left: 50%;
  }
  
  .form-box {
    position: absolute;
    right: 0;
    width: 50%;
    height: 100%;
    background-color: #fff;
    display: flex;
    align-items: center;
    color: #333;
    text-align: center;
    padding: 40px;
    z-index: 1;
    transition: 0.6s ease-in-out 1.2s, visibility 0 1;
  }
  
  .box-item.active .form-box {
    right: 50%;
  }
  
  
  .form-box form {
    width: 100%;
  }
  .btn {
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border: none;
    font-size: 16px;
    color: #fff;
    font-weight: 600;
    width: 160px;
    height: 46px;
    background-color: transparent;
    border: 2px solid #fff;
    box-shadow: none;
  }  
  .social-icons {
    display: flex;
    justify-content: center;
  }
  
  .toggle-box {
    position: absolute;
    width: 100%;
    height: 100%;
  }
  
  .toggle-box::before {
    content: ""; /* 元素本身不会显示任何文本内容，但可能会显示背景、边框等其他样式。 */
    position: absolute;
    left: -250%;
    width: 300%;
    height: 100%;
    background-color: #809e4c;
    z-index: 2;
    border-radius: 150px;
    transition: 1.8s ease-in-out;
  }
  
  .one {
    position: absolute;
    width: 50%;
    height: 100%;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2;
    transition: 0.6s ease-in-out;
  }
  
  .toggle-left {
    left: 0;
    transition-delay: 1.2s;
  }
  
  .box-item.active .toggle-left {
    left: -50%;
    transition-delay: 0.6s;
  }
  
  .toggle-right {
    right: -50%;
    transition-delay: 0.6s;
  }
  
  .box-item.active .toggle-right {
    right: 0;
    transition-delay: 1.2s;
  }
  
  </style>
  